/**
 * 日期时间格式化
 */
function dateTimeFormat(dateTime) {
  if (!dateTime) {
    return "";
  }

  const year = dateTime.getFullYear();
  const month = dateTime.getMonth() + 1;
  const day = dateTime.getDate();
  const hour = dateTime.getHours();
  const minute = dateTime.getMinutes();
  const second = dateTime.getSeconds();

  return `${year}-${pad(month)}-${pad(day)} ${pad(hour)}:${pad(minute)}:${pad(second)}`;
}

/**
 * 数字字符串填充，将一位的数字前面填充‘0’
 */
function pad(num) {
  return num.toString().padStart(2, '0');
}

module.exports = {
  "dateTimeFormat": dateTimeFormat
}